import service from '@/utils/request'

export function getAllUniversity() {
  return service({
    url: `/orgs/univ/`,
    method: 'get'
  })
}

export function getUniversity(pageNum: number, pageSize: number) {
  return service({
    url: `/orgs/univ/${pageNum}/${pageSize}`,
    method: 'get'
  })
}

export async function addUniversity(data: object) {
  return await service({
    url: `/orgs/univ/addOneUniv`,
    method: 'post',
    data
  })
}

export function updateUniversity(id: string, data: object) {
  return service({
    url: `/orgs/univ/{upUnivById}?univId=${id}`,
    method: 'put',
    data
  })
}

export function searchUniversityByName(queryInfo: string, pageIndex: number, pageSize: number) {
  return service({
    url: `/orgs/univ/searchUnivByUnivName/${pageIndex}/${pageSize}?schoolname=${queryInfo}`,
    method: 'get',
  })
}

export function deleteUniversity(id: string) {
  return service({
    url: `/orgs/univ/${id}`,
    method: 'delete',
  })
}

export function exportUniversityExcel() {
  return service({
    responseType: 'blob',
    url: '/orgs/univ/noAuthExcel/export',
    method: 'get'
  })
}

export function searchUnivByArea(queryInfo: string, pageIndex: number, pageSize: number) {
  return service({
    url: `/orgs/univ/searchUnivByCity/${pageIndex}/${pageSize}?cityId=${queryInfo}`,
    method: 'get',
  })
}
//上传excel
export function uploadUnivExcel(data: any) {
  return service({
    // url: '/minio/upload',
    url: '/orgs/univ/batchImportUnivs',
    method: 'post',
    // headers: {
    //   "Content-Type": "multipart/form-data"
    // },
    data,
  })
}